import request from '@/utils/request'

//登录
export function login(data) {
  return request({
    url: '/pub/login',
    method: 'post',
    data,
  })
}

//退出
export function logout(data) {
  return request({
    url: '/pub/logout',
    method: 'get',
  })
}

//获取当前登录用户信息
export function getCurrentUser() {
  return request({
    url: '/pub/currentUser',
    method: 'get',
  })
}

//修改密码
export function updatePassword(data) {
  return request({
    url: '/pub/updatePassword',
    method: 'post',
    data,
  })
}

//重置密码
export function resetPassword(username) {
  return request({
    url: '/pub/resetPassword/' + username,
    method: 'post',
  })
}

//导出excel模板
export function exportTemplateExcel(type) {
  return request({
    url: `/pub/downloadexcel/${type}`,
    method: 'get',
    responseType: 'blob',
  })
}

//获取当版本
export function getPubVersion() {
  return request({
    url: '/pub/spd/version',
    method: 'get',
    isNotTokent: true,
    showLoading: true,
  })
}

//下载
export function downloadApp(data) {
  return request({
    url: '/pub/downloadApp/' + data,
    method: 'get',
    responseType: 'blob',
  })
}
export function downloadDoc(data) {
  return request({
    url: '/pub/downloadDoc/' + data,
    method: 'get',
    responseType: 'blob',
  })
}

//登录-获取验证码
export function getVerify(data) {
  return request({
    url: '/pub/getVerify',
    method: 'post',
    data,
  })
}

//登录-获取验证码
export function getIsNeedVerify(data) {
  return request({
    url: '/pub/getIsNeedVerify',
    method: 'post',
    data,
  })
}

//登录-验证验证码
export function validationVerifyCode(data) {
  return request({
    url: '/pub/validationVerifyCode',
    method: 'post',
    data,
  })
}

//登录-当前登录用户是否需要修改密码
export function isChangePassword() {
  return request({
    url: '/pub/isChangePassword',
    method: 'get',
  })
}

//单点登录
export function singleLogin(data) {
  return request({
    url: '/pub/single',
    method: 'post',
    data,
  })
}

export function hisLogin(data) {
  return request({
    url: '/his/login',
    method: 'post',
    data
  })
}

export function exportTemplateImage(type) {
  return request({
    url: `/pub/file/download`,
    method: 'get',
    params: {
      fileName: type,
    },
    responseType: 'blob',
  })
}
